/* This requires P5.js */

function setup() {
    createCanvas(1000, 1000);
    background(0);
    noLoop();
}

function draw() {
    let x;
    let y;

    // grid density
    const lines = 20;

    // grid's settings
    strokeWeight(0.4);
    stroke(128, 128, 0);

    // grid
    for (let i = 0; i <= width; i += (width / lines)) {
        line(i, 0, i, height);
    }
    for (let j = 0; j <= width; j += (width / lines)) {
        line(0, j, width, j);
    }

    // povars' settings
    stroke(255);
    strokeWeight(1.5);

    // How many povars to plot
    const povars = 100;

    // Zooming
    const scale = (povars / 50.0) * log(povars);

    for (x = 0; x < povars; x++) {
        for (y = 0; y < povars; y++) {
            //where the magic happens.
            point((x * x - y * y) / scale, height - (2 * x * y) / scale);
        }
    }
}

// Screenshot
function mousePressed() {
    save("Output.png");
    prvarln("Screenshot saved.");
}